在 httpd.conf 裡面,
開放以下模組功能LoadModule status_module modules/mod_status.so
加入以下設定<Location "/server-status">
SetHandler server-status
Require ip 10.99.1.123
</Location>
透過此連結可看到系統資訊http://127.0.0.1/server-status?refresh=10
查看 Apache 版本資訊/usr/local/apache_2.4.65/bin/httpd -V
計算 Apache 總記憶體使用量ps aux | grep 'httpd' | awk '{ total += $6; } END { print total/1024"MB" }'
計算 Apache 總 CPU 使用量ps aux | grep 'httpd' | awk '{ total += $3; } END { print total"%" }'
查看當前正在運行的 Apache 進程數ps faux|grep 'httpd' |wc -l
查看所有進程下運行的 Apache 線程總數, MaxRequestWorkers的設定值需大於此值ps -eLf|grep 'httpd' |wc -l
查看在特定 Apache 進程下運行的線程數ps -eLf|grep $程序編號 |wc -l
查看當前的連接數狀況netstat -nat|awk '{print awk $NF}'|sort|uniq -c|sort -n
linux 下獲取佔用 CPU 資源最多的 10 個進程ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head
linux 下獲取佔用內存資源最多的 10 個進程ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head
列出系統上最耗費記憶體的程式ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
前 10 個最耗費記憶體的行程top -b -o +%MEM | head -n 17
找出最耗費 CPU 資源的行程top -b -o +%CPU | head -n 17
查看和 Apache 相關的連線netstat -ae|grep www-data
查看目前連線數最高的IPnetstat -nat|grep ":80"|awk '{print $5}' |awk -F: '{print $1}' | sort| uniq -c|sort -n